import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import http from './utils/http'

import ElementUI from 'element-ui'
import api from './api'

import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/protal.css'
import moment from 'moment'
import echarts from 'echarts'
import VueQuillEditor from 'vue-quill-editor'
import VueParticles from './components/vue-particles'

//import VueAMap from 'vue-amap';

Vue.prototype.$echarts = echarts
Vue.prototype.$moment = moment

Vue.use(VueQuillEditor)

Vue.use(VueParticles)

//Vue.use(VueAMap);
Vue.config.productionTip = false

//百度地图
// VueAMap.initAMapApiLoader({
//   key: '	3f5bdc7cb6cfffbafe7fbbb18528d7bb',
//   plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
//   // 默认高德 sdk 版本为 1.4.4
//   v: '1.4.4'
// });

Vue.prototype.$http = http
Vue.prototype.api = api

//全局时间格式化过滤
Vue.filter('dateFormat', function (value, formatString) {
	if (value == undefined) {
		return "";
	}
    formatString = formatString || 'YYYY-MM-DD HH:mm:ss';
    return moment(value).format(formatString);
});

//按钮权限校验
Vue.directive('has', {
	//bind下报错替换成inserted
	inserted: function (el, binding) {
		if (!hasPermission(binding.value)) {
			el.parentNode.removeChild(el);
		}

		function hasPermission(value) {
			const buttons = store.getters.buttons;
			return buttons!=null && buttons.indexOf(value) > -1;
		}
	}
});

//路由跳转后返回顶部
router.afterEach((to,from,next) => {
  window.scrollTo(0,0);
});

Vue.use(ElementUI, {size: 'small', zIndex: 3000})
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
}).$mount('#app')
